package com.future.controller;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志打印控制器
 *
 * @author shiyong
 * 2022/2/14 16:48
 */
@RestController
@RequestMapping("/log")
@Slf4j
public class LogController {

    /**
     * 打印debug级别的日志
     *
     * @return com.alibaba.fastjson.JSONObject
     * @author shiyong
     * 2022/2/15 9:57
    */
    @PostMapping("/printDebugLog")
    public JSONObject printDebugLog() {
        log.debug("打印debug级别的日志");

        JSONObject result = new JSONObject();
        result.put("result", "ok");
        return result;
    }

    /**
     * 打印info级别的日志
     *
     * @return com.alibaba.fastjson.JSONObject
     * @author shiyong
     * 2022/2/14 17:11
    */
    @PostMapping("/printInfoLog")
    public JSONObject printInfoLog() {
        log.info("打印info级别的日志");

        JSONObject result = new JSONObject();
        result.put("result", "ok");
        return result;
    }

    /**
     * 打印warn级别的日志
     *
     * @return com.alibaba.fastjson.JSONObject
     * @author shiyong
     * 2022/2/15 9:44
    */
    @PostMapping("/printWarnLog")
    public JSONObject printWarnLog() {
        log.warn("打印warn级别的日志");

        JSONObject result = new JSONObject();
        result.put("result", "ok");
        return result;
    }

    /**
     * 打印error级别的日志
     *
     * @return com.alibaba.fastjson.JSONObject
     * @author shiyong
     * 2022/2/15 9:58
    */
    @PostMapping("/printErrorLog")
    public JSONObject printErrorLog() {
        log.error("打印error级别的日志");

        JSONObject result = new JSONObject();
        result.put("result", "ok");
        return result;
    }
}
